/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fileOprs;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintStream;

/**
 *
 * @author Ganesh
 */
public class FileSystemOut {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        PrintWriter out=null;
        try {
            // TODO code application logic here
            out = new PrintWriter(new FileWriter("output.txt",true));
            out.println("HelloPrintWriter outPrintWriter outPrintWriter\n\ttPrintWriter out");
            out.flush();
            System.out.println("Completed");
        } catch (IOException ex) {
            Logger.getLogger(FileSystemOut.class.getName()).log(Level.SEVERE, null, ex);
        }


        ///////
                try{
             PrintStream printStreamOut = new PrintStream(new FileOutputStream(new File("SYSOUT.txt")));
             System.setOut(printStreamOut);

             PrintStream printStreamErr = new PrintStream(new FileOutputStream(new File("SYSERR.txt")));
             System.setErr(printStreamErr);
         System.out.println("Hi how are you");
         }catch(Exception e){
            System.out.println("Error");
         }
        
    }

}
